package com.lgkj.zhm.TestZone;

import com.digital.szzz.gateway.sdk.api.GatewaySender;
import com.digital.szzz.gateway.sdk.bean.GatewayResponse;
import com.digital.szzz.gateway.sdk.util.AesUtil;

import java.nio.charset.StandardCharsets;
import java.util.Map;

public  class ZhmUtil {


    public static Map<String, Object> ZXPersonHeal(String idCode) {
        String body = "idCardType=1&idCardNo="+idCode;
        String appId = "z8nVh42F";
        String method = "szzz.user.healthinfo.get";
        String ivStr = "NI5z72yjb90/wk5MxHIy0g==";
        String keyStr = "1kfN1Z6dgZO1yOuw3NmcRQ==";
        String secretKey = "frY7aJoO";
        GatewayResponse response = GatewaySender.send(appId, method, ivStr, keyStr, secretKey, body, 2000, 2000);
        if (response.getCode() != 200) {
            return TypeConversionUtil.stringToMap(response.getMessage());
        }
        byte[] data = AesUtil.base64ToByte(response.getData());
        byte[] plainData = AesUtil.decrypt(AesUtil.base64ToByte(ivStr), AesUtil.base64ToByte(keyStr), data);
        String result =  new String(plainData, StandardCharsets.UTF_8);
        Map<String, Object> resultMap = TypeConversionUtil.stringToMap(result);
        // String expectSign = response.getSign();
        return resultMap;
    }//end ZXPersonHeal 人员健康码
}
